﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;


namespace TeamProject
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public Boolean homeOpen;
        private void Form1_Load(object sender, EventArgs e)
        {
            Home f_Home = new Home();
            f_Home.MdiParent = this;
            f_Home.Show();
            homeOpen = true;
        }

        private void изходToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void информцияToolStripMenuItem_Click(object sender, EventArgs e)
        {

            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is InsCompany)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new InsCompany(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }

        }

        private void продуктиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Insurance.InsProducts)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Insurance.InsProducts(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void обектиToolStripMenuItem_Click(object sender, EventArgs e)
        {
             Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Insurance.InsObjects)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Insurance.InsObjects(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void добавянеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Policy.PolInfo)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Policy.PolInfo(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void плащанияПоToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Policy.PolPayments)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Policy.PolPayments(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }
        private void предстоящиПадежиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Policy.UpcomingPayment)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Policy.UpcomingPayment(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void просрочениВноскиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Policy.Standing)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Policy.Standing(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }
        private void информацияЗаКлиентитеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Client.ClientInfo)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Client.ClientInfo(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void създаванеНаСправкаToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Reports.AgentReport)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Reports.AgentReport(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void справкаПостъпилиПлащанияToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Reports.InPaymentsReport)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Reports.InPaymentsReport(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }

        private void справкаСумиЗаЗастрахователиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Reports.ForInsCompReport)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Reports.ForInsCompReport(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }

        }

        private void началоToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form instance = null;
            // Looking for MyForm among all opened forms 
            foreach (Form form in Application.OpenForms)
            {
                if (form is Home)
                {
                    instance = form;
                    instance.MdiParent = this;
                    break;
                }
            }
            if (Object.ReferenceEquals(null, instance))
            {
                // No opened form, lets create it and show up:
                instance = new Home(); //case
                instance.MdiParent = this;
                instance.Show();
            }
            else
            {
                if (instance.WindowState == FormWindowState.Minimized)
                    instance.WindowState = FormWindowState.Normal;
                instance.BringToFront();
                if (instance.CanFocus)
                {
                    instance.Focus();
                }
            }
        }




        private void button1_Click(object sender, EventArgs e)
        {
            panel1.Visible = false;
        }

       

       

        
    }
}
